<?php
/*
Uploadify v3.1.0
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/

// Define a destination
define('web_s', 'johnsongod');
require $_SERVER['DOCUMENT_ROOT'].'/admin/includes/init.php';
require $_SERVER['DOCUMENT_ROOT'].'/admin/includes/session.php';
$datetime = date('Ymd');
$datetime1 = date('YmdHis');
$rndnum = rand(100000,999999);
$targetFolder = $_SERVER['DOCUMENT_ROOT'].'/images/'.$datetime.'/'; // Relative to the root
MkFolder($targetFolder);
$filename=$_FILES['fileToUpload']['name'];
$filet=$_FILES['fileToUpload']['tmp_name'];
for($i=0;$i<count($filename);$i++){
	$temp = pathinfo($filename[$i]);
	move_uploaded_file($filet[$i],$targetFolder.$datetime1.'.'.$temp['extension']);
	chmod($targetFolder.$datetime1.'.'.$temp['extension'], 0777);
	$db->autoExecute('m_goods_pic', array('goods_id' => 0, 'thumb' => $datetime.'/'.$datetime1.'.'.$temp['extension'], 'pic_url' => $datetime.'/'.$datetime1.'.'.$temp['extension']), 'INSERT');
}
function MkFolder($path){
	if(!is_readable($path)){
		MkFolder( dirname($path) );
		if(!is_file($path)) mkdir($path,0777);
	}
}
?>
<script type="text/javascript" src="/static/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$('#imglist',top.document).load('/admin/piclist.php');
$('#uploadimgform',top.document).show();
$('#loading',top.document).hide();
</script>